/**
 * 解决 umi 自身的bug
 */
const fs = require('fs');
const path = require('path');

let assetManifestStr = fs.readFileSync('./dist/asset-manifest.json');
let assetManifest = JSON.parse(assetManifestStr);

// render 文件内容
const filepath = path.resolve(__dirname, './dist/umi.server.js');

let str = fs.readFileSync(filepath).toString();

str = str.replace(/\/dist\/umi\.css/g, assetManifest['umi.css']);
str = str.replace(/\/dist\/umi\.js/g, assetManifest['umi.js']);

fs.writeFileSync(filepath, str);
